package com.lagou.interceptors;

import org.springframework.web.servlet.HandlerInterceptor;

public class AuthInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        System.out.println("权限拦截器 拦截"+request.getRequestURI());
        if(request.getRequestURI().endsWith("login")) {
            return true;
        }
        if(request.getSession().getAttribute("username")!=null) {
            return true;
        }
        request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
        return false;
    }

}
